package com.pro.springbootshop.controller;

import com.pro.springbootshop.entityExtend.HistoryOrderReturn;
import com.pro.springbootshop.entityExtend.SearchOrder;
import com.pro.springbootshop.service.HistoryOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class HistoryOrderController {
    @Autowired
    HistoryOrderService historyOrderService;
    @ApiOperation("商家获取所有历史记录")
    @PostMapping("/api/historyOrder")
    public HistoryOrderReturn getHistoryOrderList(@RequestBody SearchOrder searchOrder){
        return historyOrderService.getHistoryOrderList(searchOrder);
    }
    @ApiOperation("删除历史记录")
    @PostMapping("/api/historyOrder/{historyOrderId}")
    public String deleteHistoryOrder(@PathVariable(name = "historyOrderId") String historyOrderId){
        return historyOrderService.deleteHistoryOrder(historyOrderId);
    }
    @ApiOperation("获取历史记录")
    @GetMapping("/api/historyOrder/{page}/{limit}")
    public HistoryOrderReturn getOrderList(@PathVariable(name = "page") Integer page, @PathVariable(name = "limit") Integer limit, HttpServletRequest request){
        String token = request.getHeader("token");
        return historyOrderService.getOrderList(page,limit,token);
    }
}
